package debtbundler.domain.entity.impl;

import java.io.Serializable;
import java.util.Calendar;

abstract class AbstractEntity implements Serializable {
	private static final long serialVersionUID = 1L;
	
	protected Calendar createdDate;
	protected String createdBy;
	protected Calendar updatedDate;
	protected String updatedBy;
	
	protected AbstractEntity() {
		this.createdDate = Calendar.getInstance();
		this.createdBy = System.getProperty("user.name");
		this.updatedDate = createdDate;
		this.updatedBy = createdBy;
	}
	
	public Calendar getCreatedDate() {
		return createdDate;
	}
	public String getCreatedBy() {
		return createdBy;
	}
	public Calendar getUpdatedDate() {
		return updatedDate;
	}
	public String getUpdatedBy() {
		return updatedBy;
	}

	/**
	 * Sets values of updatedDate and updatedBy to current time and OS user name.
	 */
	protected void markUpdated() {
		this.updatedDate = Calendar.getInstance();
		this.updatedBy = System.getProperty("user.name");
	}
	
}
